package com.sean.reverse.util;

import javax.servlet.http.HttpServletResponse;

/**
 * des: 返回结果状态
 * @author HuZhenSha
 * @date 2021/3/5 15:23
 */
public enum ResultCode implements IResultCode{

    /**
     * 成功
     */
    SUCCESS(HttpServletResponse.SC_OK, "操作成功"),

    /**
     * 业务异常
     */
    FAILURE(HttpServletResponse.SC_BAD_REQUEST, "业务异常"),

    /**
     * 请求未授权
     */
    UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "请求未授权"),

    /**
     * 404 没找到请求
     */
    NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "404 没找到请求"),

    /**
     * 消息不能读取
     */
    MSG_NOT_READABLE(HttpServletResponse.SC_BAD_REQUEST, "消息不能读取"),

    /**
     * 不支持当前请求方法
     */
    METHOD_NOT_SUPPORTED(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "不支持当前请求方法"),

    /**
     * 不支持当前媒体类型
     */
    MEDIA_TYPE_NOT_SUPPORTED(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"),

    /**
     * 请求被拒绝
     */
    REQ_REJECT(HttpServletResponse.SC_FORBIDDEN, "请求被拒绝"),

    /**
     * 服务器异常
     */
    INTERNAL_SERVER_ERROR(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器异常"),

    /**
     * 缺少必要的请求参数
     */
    PARAM_MISS(HttpServletResponse.SC_BAD_REQUEST, "缺少必要的请求参数"),

    /**
     * 请求参数类型错误
     */
    PARAM_TYPE_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数类型错误"),

    /**
     * 请求参数绑定错误
     */
    PARAM_BIND_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数绑定错误"),

    /**
     * 参数校验失败
     */
    PARAM_VALID_ERROR(HttpServletResponse.SC_BAD_REQUEST, "参数校验失败"),


    UNKNOWN_ERROR(20000, "未知错误"),
    VALIDATION_ERROR(20001,"参数校验错误"),
    DUPLICATED_KEY_ERROR(20002,"重复的主键"),
    NONE_KEY_ERROR(20003,"主键不存在"),
    FOREIGN_KEY_ERROR(20004,"存在外键约束"),
    CONTENT_TYPE_ERROR(20005,"请检查content-type"),
    DUPLICATED_RECORD_ERROR(20006, "该记录已经存在"),
    NONE_RECORD_ERROR(20007, "该记录不存在"),
    CONTENT_ERROR(20008, "提交内容有误"),
    FIlE_NOT_EXIST_ERROR(20009, "文件不存在"),

    DUPLICATED_ACCOUNT(20019, "用户名已存在"),
    DUPLICATED_WORK_NUM(20020, "工号已存在"),


    PAGINATION_ERROR(6015, "分页错误"),
    SCHEDULER_ERROR(6016, "定时器错误");


    private final int code;

    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }


}
